import { http } from './service.js'

//线索列表
export const getMyLeads = (areaId, staffId, pageNum, pageSize) => {
	return http.request({
		url: 'crm/web/leads/page',
		method: 'POST',
		params: {
			'areaId': areaId,
			'staffId': staffId,
			'pageNum': pageNum,
			'pageSize': pageSize
		}
	})
}
//线索详情
export const getLeadsDetailWithClientele = (leadsId) => {
	return http.request({
		url: 'crm/web/leads/detail_with_clientele',
		method: 'POST',
		params: {
			'leadsId': leadsId
		}
	})
}
//线索跟踪信息
export const getLeadsFollow = (leadsId) => {
	return http.request({
		url: 'crm/web/leadsHistory/find_by_leadsId',
		method: 'POST',
		params: {
			'leadsId': leadsId,
			'pageNum': 0,
			'pageSize': 99,
		}
	})
}
//添加线索
export const addLeads = (data) => {
	return http.request({
		url: 'crm/web/leads/add',
		method: 'POST',
		params: data
	})
}
//续约客户
export const getContinueClientelePage = (data) => {
	console.log(data);
	// return http.post('crm/web/clientele/continue_clientele_page', data )
	return http.request({
		url: 'crm/web/clientele/continue_clientele_page',
		method: 'POST',
		params: data
	})
}
//客户
export const getClientele = (data) => {
	console.log(data);
	return http.post('crm/web/clientele/page', data )
	// return http.request({
	// 	url: 'crm/web/clientele/continue_clientele_page',
	// 	method: 'POST',
	// })
}

//客户基本信息
export const getClienteleDetail = (clientelesId) => {
	return http.request({
		url: 'crm/web/clientele/detail',
		method: 'POST',
		params: {
			'clientelesId': clientelesId
		}
	})
}
//客户跟踪信息
export const getClienteleFollow = (clientelesId) => {
	return http.request({
		url: 'crm/web/leadsHistory/find_by_clientelesId',
		method: 'POST',
		params: {
			'clientelesId': clientelesId,
			'pageNum': 0,
			'pageSize': 99,
		}
	})
}
// 线索添加跟进信息
export const addFollow = (data) => {
	// return http.post('crm/web/leadsHistory/add', data, {
	// 	header: {
	// 		'content-type': 'application/x-www-form-urlencoded'
	// 	},
	// })
	return http.request({
		url: 'crm/web/leadsHistory/add',
		method: 'POST',
		params: data,
		// header: {
		// 	'content-type': 'application/x-www-form-urlencoded'
		// },
	})
}

//销售faq
export const getFaqPage = (keyWords, pageNum, pageSize) => {
	return http.request({
		url: 'pad/saleFAQ/getPage',
		method: 'POST',
		params: {
			'keyWords': keyWords,
			'pageNum': pageNum,
			'pageSize': pageSize
		}
	})
}
//我的faq
export const getPageByStaffId = (areaId, pageNum, pageSize) => {
	return http.request({
		url: 'pad/saleFAQ/getPageByStaffId',
		method: 'POST',
		params: {
			'areaId': areaId,
			'pageNum': pageNum,
			'pageSize': pageSize
		}
	})
}

export const addFaq = (areaId, question, answer) => {
	console.log('addFaq');
	return http.request({
		url: 'pad/saleFAQ/add',
		method: 'POST',
		params: {
			'areaId': areaId,
			'question': question,
			'answer': answer
		}
	})
}
//faq审核列表
export const getPageByState = (pageNum, pageSize) => {
	return http.request({
		url: 'pad/saleFAQ/getPageByState',
		method: 'POST',
		params: {
			'pageNum': pageNum,
			'pageSize': pageSize
		}
	})
}
//审核
export const updateById = (id, state) => {
	return http.request({
		url: 'pad/saleFAQ/updateById',
		method: 'POST',
		params: {
			'id': id,
			'state': state
		}
	})
}

export const getAllChannel = (areaId) => {
	return http.request({
		url: 'crm/web/channel/all',
		method: 'POST',
		params: {
			'areaId': areaId
		}
	})
}

export const getProduct = (params) => {
	console.log(params);
	return http.request({
		url: 'crm/web/product/page',
		method: 'GET',
		params
	})
}

export const addContract = (params) => {
	return http.request({
		url: 'crm/web/contract/add',
		method: 'POST',
		header: {
			'content-type': 'application/x-www-form-urlencoded'
		},
		data: params
	})
}

export const getClienteleByChildrenId = (params) => {
	return http.request({
		url: 'crm/web/clientele/childrenIdDetail',
		method: 'GET',
		params: params
	})
}

export const changeClientele = (params, data) => {
	return http.request({
		url: 'crm/web/clientele/change_clientele',
		method: 'POST',
		header: {
			'content-type': 'application/x-www-form-urlencoded'
		},
		params,
		data
	})
}
